<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">

  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>金蝶云星 数据查询</title>
  <link rel="stylesheet" crossorigin="anonymous"
    href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.6.1/css/bootstrap.min.css">
  <link rel="stylesheet" crossorigin="anonymous"
    href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.1/animate.min.css">

  <link rel="stylesheet" crossorigin="anonymous"
    href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.18.0/bootstrap-table.min.css">


  <link rel="stylesheet" crossorigin="anonymous"
    href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.18.0/themes/bootstrap-table/bootstrap-table.min.css">

  <style>
    .glassbga {
      /*渐变*/
      background: linear-gradient(to right bottom, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0.2));
      ;
      border-radius: 1rem;
      box-shadow: 6px 6px 10px rgba(112, 112, 112, 0.2);
    }

    .glassbg {
      /*背景*/
      background: linear-gradient(to right top, #65dfc9, #6cdbeb);
      border-radius: 1rem;
    }

    .offbut {
      transform: translateY(125%);
      /**上移元素**/

    }

    [v-cloak] {
      display: none;
    }
  </style>
</head>


<body id="q-app" class="glassbg text-white  ">

  <!---上面的结果框val--->
  <div v-cloak class="container ">
    <div class="mt-2 row justify-content-center  ">
      <div class="w-100 mb-5   d-none d-md-block"><!---高度垫子 小设备隐藏--></div>
      <div>
        <h3>数据</h3>
      </div>

    </div>
  </div>

  <!--功能选择--->
  <transition v-cloak enter-active-class="animated bounceIn" leave-active-class="animated bounceOut">
    <div v-cloak class=" container-fluid    justify-content-center    glassbga  mt-4  mb-4  px-4  pt-3  pb-3  ">

      <div class=" justify-content-center  ">


        <ul class="nav nav-tabs   ">
          <li class="nav-item">
            <a class="nav-link shadow  bg-secondary  text-white  px-1 px-sm-3 px-lg-5 mx-1 mx-sm-2 mx-lg-1   "
              @click="er.emit('swtab' ,'代办任务')  " :class="[{' active bg-info ': ('代办任务' == pd.tabSele )} ]">代办任务</a>
          </li>
          <li class="nav-item" id="prac">
            <a class="nav-link shadow   bg-secondary text-white  px-1 px-sm-3 px-lg-5 mx-1 mx-sm-2 mx-lg-2"
              @click="er.emit('swtab' ,'系统单据')    " :class="[{' active bg-info ': ('系统单据' == pd.tabSele )} ]">系统单据</a>
          </li>
          <li class="nav-item" id="prac">
            <a class="nav-link shadow   bg-secondary text-white  px-1 px-sm-3 px-lg-5 mx-1 mx-sm-2 mx-lg-2"
              @click="er.emit('swtab' ,'用户账号')    " :class="[{' active bg-info ': ('用户账号' == pd.tabSele )} ]">用户账号</a>
          </li>
          <li class="nav-item" id="prac">
            <a class="nav-link shadow   bg-secondary text-white  px-1 px-sm-3 px-lg-5 mx-1 mx-sm-2 mx-lg-2"
              @click="er.emit('swtab' ,'物料价格')    " :class="[{' active bg-info ': ('物料价格' == pd.tabSele )} ]">物料价格</a>
          </li>

          <li class="nav-item" id="prac">
            <a class="nav-link shadow   bg-secondary text-white  px-1 px-sm-3 px-lg-5 mx-1 mx-sm-2 mx-lg-2"
              @click="er.emit('swtab' ,'业务流程')    " :class="[{' active bg-info ': ('业务流程' == pd.tabSele )} ]">业务流程</a>
          </li>


        </ul>
        <!-- 表1-->
        <div :class="[{' d-none ': ! (  '代办任务' == pd.tabSele )} ]">

          <button @click="er.emit('筛选代办任务' ,'处理中') " type="button" class="btn mx-2 btn-primary offbut">处理中</button>
          <button @click="er.emit('筛选代办任务' ,'已完成') " type="button" class="btn mx-2 btn-primary offbut">已完成</button>
          <button @click="er.emit('筛选代办任务' ,'错误') " type="button" class="btn mx-2 btn-primary offbut">错误</button>
          <!--表数据--->
          <table class="  bg-white" id="代办任务tab"></table>

        </div>

        <!-- 表1-->
        <div :class="[{' d-none ': ! (  '用户账号' == pd.tabSele )} ]">
          <!--表数据--->
          <table class="  bg-white" id="用户账号tab"></table>
        </div>


        <!-- 表-物料价格-->
        <div :class="[{' d-none ': ! (  '物料价格' == pd.tabSele )} ]">
          <!--表数据--->
          <table class="  bg-white" id="物料价格tab"></table>
        </div>


        <!-- 表2-->
        <div :class="[{' d-none ': ! (  '系统单据' == pd.tabSele )} ]">
          <div v-if="1==0" class="container-md    mt-2     pt-3  pb-3">
            <div class=" row  align-items-center   justify-content-around  ">
              <div class="col-4  p-0 d-flex col-1 col-md-1 col-sm-1  justify-content-end  ">
                <label class="text-dark mt-1 ">系统单据</label>
              </div>
              <div class="  p-0 col-6   col-md-4 col-sm-4   align-items-center  justify-content-start ">
                <input type="text" v-model="pd.searchCol" class="  form-control" placeholder="请输入名字">
              </div>

              <div class="   d-flex col-auto   justify-content-start  ">
                <button @click="er.emit('全局查询单据类型' ) " class="btn shadow-lg btn-danger">全局查询</button>
              </div>
            </div>
          </div>
          <!--表数据--->
          <table class="  bg-white" id="单据类型tab"></table>

        </div>
      </div>

    </div>
  </transition>




  <!---上面的结果框val--->
  <div v-cloak class="container-sm ">

    <div class="  row justify-content-center  ">


    </div>
  </div>



  <!---info提示信息--->
  <transition v-cloak mode="out-in" enter-active-class="animated pulse" leave-active-class="animated bounceOutRight">
    <div class=" container-sm  fixed-top    " style="z-index: 1083 ;" v-for="site in pd.info_list">
      <div class="alert  alert-warning alert-dismissible fade show" role="alert">
        <strong>{{site.type}}</strong>{{ site.info }}
        <button type="button" class="close" data-dismiss="alert" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
    </div>
  </transition>
  <!---遮罩1024--->
  <div v-cloak v-if="pd.sp==0?false:true" @click="er.emit('遮罩',0) " style="z-index: 1081  ;"
    class=" modal-backdrop show ">

  </div>
  <!---载入动画--->
  <transition v-cloak leave-active-class="animated fadeOut">
    <div v-if="pd.sp==0?false:true" class="  w-100 mt-5   row d-flex     align-items-center  justify-content-center  "
      style="z-index: 1082  ;">
      <div class="spinner-border   "></div>
    </div>
  </transition>




  <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/3.2.47/vue.global.prod.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.10.0/lodash.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/EventEmitter/5.2.8/EventEmitter.min.js"></script>

  <script src="https://cdnjs.cloudflare.com/ajax/libs/axios/1.4.0/axios.min.js"></script>


  <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.4/moment.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js"></script>

  <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.18.0/bootstrap-table.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.18.0/bootstrap-table-vue.min.js"></script>
  <script
    src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.18.0/locale/bootstrap-table-zh-CN.min.js"></script>

  <script src="https://cdnjs.cloudflare.com/ajax/libs/URI.js/1.19.11/URI.min.js"></script>



  <script src="./danfo1.1.2.js"></script>
  <!---bootstraptable行合并  onLoadSuccess  mergeCells-->



  <script>
    const er = new EventEmitter //事件线
    const { onMounted, emits, createApp, ref, watch, computed } = Vue

    const gd = {};//全局数据 解决调用引用问题
    gd.group = 'dataDict' //功能应用分组
    gd.reg = {} //组成类到全局调用
    gd.storage = {
      //本地浏览器 存取组件
      set(key, value, area) {
        key = area ? area + ':' + key : key;//分区域分区组
        key = gd.group + '.' + key;//分组
        localStorage.setItem(key, JSON.stringify(value));
      },
      get(key, area) {
        key = area ? area + ':' + key : key;//分区域分区组
        key = gd.group + '.' + key;//分组
        return JSON.parse(localStorage.getItem(key));
      },
      remove(key, area) {
        key = area ? area + ':' + key : key;//分区域分区组
        key = gd.group + '.' + key;//分组
        localStorage.removeItem(key);
      },
    }
    gd.pd = ref({});//page data 页面元素引用"数据"
    //const pd = ref({ "load": [] }); //特殊变量，页面数据
    const pvs = gd.pd.value; //变量代理访问
    pvs.datUrl = `//${new URI().hostname()}:2028/jsonapi/get`;
    class pgui {
      /* 界面控制类 初始化界面默认值 */
      constructor(arg) {
        //初始（值）
        //----页面参数
        pvs.url = new URI() //获取去 type，pid ，默认访问本站，数据加载主站

        //--界面值
        gd.reg.ui = this//全局资源
        pvs.sp = 0; //遮罩路由 (0.无，1.名单，2.登入 ,3.管理)
        pvs.info_list = []//交互提示 {info:"2",type:"2"}
        pvs.rawDat = {} //原始数据

        //pvs.searchTab = gd.storage.get('searchTab') ? gd.storage.get('searchTab') : '';//'默认查询名
        //--存储默认值

        pvs.tabSele = gd.storage.get('tabSele') ? gd.storage.get('tabSele') : '代办任务';//'默认路径'
        pvs.rowBase = []  //基本信息
        //初始效果

        this.init();
      }

      init() {
        //初始（设置）
        //绑定事件
        er.on('swtab', this.swtab)
        er.on('遮罩', this.spto)


        //er.on('获取音标', this.toGetPh) //获取音标
        er.on('看指定单据', this.seeCol)
        er.on('看指定流程', this.seeTab)
      }

      swtab(name) {
        //切换标签，请求加载数据
        console.log('切换标签到', name)
        pvs.tabSele = name

        er.emit('查询' + name); //已经登入刷新处理

      }

      seeCol(id, name) {
        //看数据字段
        console.log('看数据字段', id, name)

      }
      seeTab(text) {
        var op = $('#代办任务tab').bootstrapTable("getOptions")
        console.log(op.searchText = text, op)

        pvs.tabSele = '代办任务'

        $('#代办任务tab').bootstrapTable('refreshOptions', { searchText: text });
        $('#代办任务tab').bootstrapTable('refresh');
      }


      showTab(eid, col, dat) {
        // 生成和销毁表格
        if ($(eid).bootstrapTable("getOptions").cache == true) {
          $(eid).bootstrapTable('destroy');
          //return
        }
        $(eid).bootstrapTable({
          data: dat,        // 表格数据来源
          classes: "table table-bordered table-striped", //table-striped表示隔行变色
          theadClasses: 'thead',
          sortStable: true,
          search: true,      //是否显示表格搜索
          striped: true,     //是否显示行间隔色
          //showRefresh: true,//刷新按钮
          pageNumber: 1, //初始化加载第一页
          pagination: true,//是否分页
          sidePagination: 'client',//server:服务器端分页|client：前端分页
          pageSize: 10,//单页记录数
          //showRefresh: true,//显示刷新按钮
          pageList: [10],
          //customSearch:fnSearch,//自定义搜索，比如只搜索ID字段
          //searchText:"text",
          columns: col
        });
      }

      showTabAll(eid, col, dat) {
        // 生成和销毁表格
        if ($(eid).bootstrapTable("getOptions").cache == true) {
          $(eid).bootstrapTable('destroy');
          //return
        }
        $(eid).bootstrapTable({
          data: dat,        // 表格数据来源
          classes: "table table-bordered table-striped", //table-striped表示隔行变色
          theadClasses: 'thead',
          sortStable: true,
          search: true,                      //是否显示表格搜索
          striped: true,                      //是否显示行间隔色
          //showRefresh: true,//刷新按钮
          pagination: false,//是否分页
          sidePagination: 'client',//server:服务器端分页|client：前端分页
          pageSize: 10,//单页记录数
          pageList: [10],
          columns: col
        });
      }

      loginLoading(n) {
        //登入中效果
        pvs.loginLoding = n
      }
      spto(n) {
        //遮罩和二级界面
        /*切换界面*/
        pvs.sp = n
      }



      showInfo(info, type = '') {
        //结果提示信息 （数据驱动）
        //添加数据，来添加提示
        pvs.info_list.push({ "info": info, "type": type })
        //缺少动效
        setTimeout(function () { pvs.info_list.splice(0, 1); }, 4000);
      }



    }

    class select {
      /* 界面控制类 初始化界面默认值 */
      constructor(arg) {
        //初始（值）
        //--界面值
        gd.reg.se = this//全局资源
        //初始效果
        this.hd = { //请求头
          mode: 'cors',
          cache: 'no-cache',
          "headers": {
            'Content-Type': 'application/json'
          }
        }


        this.init();
      }

      init() {

        //初始（设置）
        er.on('查询物料价格', this.查询物料价格)
        er.on('查询物料价格2show', this.查询物料价格2show)
        //绑定事件 
        er.on('查询用户账号', this.查询用户账号)
        er.on('查询用户账号2show', this.查询用户账号2show)

        er.on('查询代办任务', this.查询代办任务)
        er.on('筛选代办任务', this.查询代办任务)
        //er.on('筛选处理中', this.查询代办任务)
        er.on('查询代办任务2show', this.查询代办任务2show)
        //--
        er.on('查询系统单据', this.查询系统单据)
        er.on('查询系统单据2show', this.查询系统单据2show)

      }
      查询物料价格(name) {
        //查询字段数据
        const ui = gd.reg.ui
        const se = gd.reg.se

        var vn = vn = {
          "erp/T_PUR_POORDERENTRY%采购过的物料": {
            "@column": "FENTRYID.max.明细id ",
            "@group": 'FMATERIALID'
          },
          "erp/T_PUR_POORDERENTRY": {
            "@column": "FENTRYID.明细id,FID.单据id,FMATERIALID.物料id,F_QINL_WGBZ.委外备注,F_QINL_WWBZ.外购备注",
            'FENTRYID|': 'erp/T_PUR_POORDERENTRY%采购过的物料.明细id',
          },
          "erp/T_PUR_POORDERENTRY_F": {
            "@column": "FENTRYID.明细id,FID.单据id,FPRICE.价格",
            'FENTRYID|': 'erp/T_PUR_POORDERENTRY%采购过的物料.明细id',
          },
          "erp/T_PUR_POORDER": {
            "@column": "FID.单据id,FBILLNO.单据编号",
            'FID|': 'erp/T_PUR_POORDERENTRY.单据id',
            'FDOCUMENTSTATUS': "C",
          },
          "erp/T_BD_MATERIAL_L%采购物料名": {
            "@column": "FMATERIALID.物料id,FNAME,FSPECIFICATIONGG.规格,F_QINL_SPECIFICATION.型号",
            'FMATERIALID|': "erp/T_PUR_POORDERENTRY.物料id",
            'FLOCALEID': 2052,
          },
          "erp/T_BD_MATERIAL%采购物料": {
            "@column": "FMATERIALID.物料id,FNUMBER.物料代码",
            'FMATERIALID|': "erp/T_PUR_POORDERENTRY.物料id",
          },

          "erp/T_SAL_ORDERENTRY%销售过的物料": {
            "@column": "FENTRYID.max.明细id ",
            "@group": 'FMATERIALID'
          },
          "erp/T_SAL_ORDERENTRY": {
            "@column": "FENTRYID.明细id,FID.单据id,FMATERIALID.物料id,F_QINL_WGBZ.委外备注,F_QINL_WWBZ.外购备注",
            'FENTRYID|': 'erp/T_SAL_ORDERENTRY%销售过的物料.明细id',
          },
          "erp/T_SAL_ORDERENTRY_F": {
            "@column": "FENTRYID.明细id,FID.单据id,FPRICE.价格",
            'FENTRYID|': 'erp/T_SAL_ORDERENTRY%销售过的物料.明细id',
            'FISFREE': 0,
          },
          "erp/T_SAL_ORDER": {
            "@column": "FID.单据id,FBILLNO.单据编号",
            'FID|': 'erp/T_SAL_ORDERENTRY.单据id',
            'FDOCUMENTSTATUS': "C",
          },
          "erp/T_SAL_ORDERFIN": {
            "@column": "FID.单据id,FEXCHANGERATE.汇率,FBILLAMOUNT_LC.本币金额,FBILLAMOUNT.金额 ",
            'FID|': 'erp/T_SAL_ORDER.单据id',
          },
          "erp/T_BD_MATERIAL_L%销售物料名": {
            "@column": "FMATERIALID.物料id,FNAME,FSPECIFICATIONGG.规格,F_QINL_SPECIFICATION.型号",
            'FMATERIALID|': "erp/T_SAL_ORDERENTRY.物料id",
            'FLOCALEID': 2052,

          },
          "erp/T_BD_MATERIAL%销售物料": {
            "@column": "FMATERIALID.物料id,FNUMBER.物料代码",
            'FMATERIALID|': "erp/T_SAL_ORDERENTRY.物料id",
          },
        }
        // //发送
        se.se(vn, pvs.datUrl, 'MATERIAL', '查询物料价格', ['查询物料价格2show'])
      }

      查询物料价格2show() {
        //跳转、翻页
        const ui = gd.reg.ui

        console.log('查询物料价格2show==', pvs.rawDat)
        var 采购明细 = new dfd.DataFrame(pvs.rawDat['erp/T_PUR_POORDERENTRY'])
        var 采购价格 = new dfd.DataFrame(pvs.rawDat['erp/T_PUR_POORDERENTRY_F'])
        var 采购单据 = new dfd.DataFrame(pvs.rawDat['erp/T_PUR_POORDER'])
        var 采购物料名 = new dfd.DataFrame(pvs.rawDat['erp/T_BD_MATERIAL_L%采购物料名'])
        var 采购物料 = new dfd.DataFrame(pvs.rawDat['erp/T_BD_MATERIAL%采购物料'])


        var 销售明细 = new dfd.DataFrame(pvs.rawDat['erp/T_SAL_ORDERENTRY'])
        var 销售价格 = new dfd.DataFrame(pvs.rawDat['erp/T_SAL_ORDERENTRY_F'])
        var 销售单据 = new dfd.DataFrame(pvs.rawDat['erp/T_SAL_ORDER'])
        var 销售物料名 = new dfd.DataFrame(pvs.rawDat['erp/T_BD_MATERIAL_L%销售物料名'])
        var 销售物料 = new dfd.DataFrame(pvs.rawDat['erp/T_BD_MATERIAL%销售物料'])
        var 销售币别 = new dfd.DataFrame(pvs.rawDat['erp/T_SAL_ORDERFIN'])

        let 采购v2 = dfd.merge({ "left": 采购明细, "right": 采购价格, "on": ["明细id"], how: "left" })
        采购v2 = dfd.merge({ "left": 采购v2, "right": 采购单据, "on": ["单据id"], how: "left" })
        采购v2 = dfd.merge({ "left": 采购v2, "right": 采购物料名, "on": ["物料id"], how: "left" })
        采购v2 = dfd.merge({ "left": 采购v2, "right": 采购物料, "on": ["物料id"], how: "left" })
        // var 单据类型 = new dfd.DataFrame(pvs.rawDat['erp/T_BAS_BILLCODERULE'])
        // var 单据名称 = new dfd.DataFrame(pvs.rawDat['erp/T_BAS_BILLCODERULE_L'])
        let 销售v2 = dfd.merge({ "left": 销售明细, "right": 销售价格, "on": ["明细id"], how: "inner" })
        销售v2 = dfd.merge({ "left": 销售v2, "right": 销售单据, "on": ["单据id"], how: "left" })
        销售v2 = dfd.merge({ "left": 销售v2, "right": 销售物料名, "on": ["物料id"], how: "left" })
        销售v2 = dfd.merge({ "left": 销售v2, "right": 销售物料, "on": ["物料id"], how: "left" })
        销售v2 = dfd.merge({ "left": 销售v2, "right": 销售币别, "on": ["单据id"], how: "left" })

        销售币别
        //采购物料.print()
        let 销售rows = dfd.toJSON(销售v2)
        let 采购rows = dfd.toJSON(采购v2)
        _.forEach(销售rows, function (value, key) {
          //整理数据
          //value.名称 = value.名称.replace('标准编码规则', '')
          //value.名称 = value.名称.replace('编码规则', '')
          value.来源 = '销售';
          value.价格 = value.价格*value.汇率;

        });
        _.forEach(采购rows, function (value, key) {
          //整理数据
          value.来源 = '采购';
          //value.名称 = value.名称.replace('编码规则', '')


        });



        const rows = 销售rows.concat(采购rows);
        console.log('row==', rows[0])
        var columns = [
          {
            field: '单据编号',
            sortable: true,
            width: 40,
            title: '单据编号'
          }, {
            field: '物料代码',
            width: 50,
            sortable: true,
            title: '物料代码'
          }, {
            field: '规格',
            width: 50,
            sortable: true,
            title: '规格'
          }, {
            field: '型号',
            width: 50,
            sortable: true,
            title: '型号'
          }, {
            field: 'FNAME',
            width: 50,
            sortable: true,
            title: '名称'
          }, {
            field: '价格',
            width: 50,
            sortable: true,
            title: '价格'
          }, {
            field: '来源',
            width: 50,
            sortable: true,
            title: '来源'
          }, {
            field: '委外备注',
            width: 50,
            sortable: true,
            title: '委外备注'
          }, {
            field: '外购备注',
            width: 50,
            sortable: true,
            title: '外购备注'
          },]

        ui.showTab('#物料价格tab', columns, rows)
      }

      查询用户账号2show() {
        //跳转、翻页
        const ui = gd.reg.ui

        console.log('查询用户账号2show==', pvs.rawDat)
        var 用户账号 = new dfd.DataFrame(pvs.rawDat['erp/T_SEC_USER'])
        var 最后登入时间 = new dfd.DataFrame(pvs.rawDat['erp/T_BAS_USERLOGINRECORD'])
        var 扩展信息 = new dfd.DataFrame(pvs.rawDat['erp/T_BAS_USERLOGINRECORD%ip'])

        let 用户账号v2 = dfd.merge({ "left": 用户账号, "right": 最后登入时间, "on": ["FUSERID"], how: "left" })
        


        // var 单据类型 = new dfd.DataFrame(pvs.rawDat['erp/T_BAS_BILLCODERULE'])
        // var 单据名称 = new dfd.DataFrame(pvs.rawDat['erp/T_BAS_BILLCODERULE_L'])

        用户账号v2.print()
        const rows = dfd.toJSON(用户账号v2)
        const ext = dfd.toJSON(扩展信息)

        _.forEach(rows, function (value, key) {
          //整理数据
          //value.名称 = value.名称.replace('标准编码规则', '')
          //value.名称 = value.名称.replace('编码规则', '')
          
          var row = _.find(ext, function(r) { return r.FUSERID == value.FUSERID &&  r.FDATETIME == value.m ; });
           
          value.ip = row?.FCLIENTIP
          value.computer = row?.FCOMPUTERNAME
        


        });

        var columns = [
          {
            field: 'FUSERID',
            sortable: true,
            width: 70,
            title: 'id'
          }, {
            field: 'FNAME',
            sortable: true,
            width: 170,
            title: '名字'
          },
          {
            field: 'FAPPGROUP',
            sortable: true,
            width: 170,
            title: '功能'
          }, {
            field: 'FDESCRIPTION',
            width: 210,
            sortable: true,
            title: '描述'
          }, {
            field: 'm',
            width: 210,
            sortable: true,
            title: '最后登入时间'
          }, {
            field: 'ip',
            width: 210,
            sortable: true,
            title: '网络地址'
          }, {
            field: 'computer',
            width: 210,
            sortable: true,
            title: '主机名'
          }]

        ui.showTab('#用户账号tab', columns, rows)
      }


      查询系统单据2show() {
        //跳转、翻页
        const ui = gd.reg.ui

        console.log('查询系统单据2show==', pvs.rawDat)
        var 单据类型 = new dfd.DataFrame(pvs.rawDat['erp/T_BAS_BILLTYPE'])
        var 单据名称 = new dfd.DataFrame(pvs.rawDat['erp/T_BAS_BILLTYPE_L'])
        var 单据表 = new dfd.DataFrame(pvs.rawDat['erp/T_BF_TABLEDEFINE'])

        // var 单据类型 = new dfd.DataFrame(pvs.rawDat['erp/T_BAS_BILLCODERULE'])
        // var 单据名称 = new dfd.DataFrame(pvs.rawDat['erp/T_BAS_BILLCODERULE_L'])

        单据类型.print()
        单据名称.print()
        单据表.print()
        let 单据类型v2 = dfd.merge({ "left": 单据类型, "right": 单据名称, "on": ["FBILLTYPEID"], how: "left" })
        单据类型v2 = dfd.merge({ "left": 单据类型v2, "right": 单据表, "on": ["单据编码"], how: "left" })

        //单据类型v2.sortValues("流程实例id", { ascending: false, inplace: true })
        单据类型v2.print()
        const rows = dfd.toJSON(单据类型v2)

        _.forEach(rows, function (value, key) {
          //整理数据
          //value.名称 = value.名称.replace('标准编码规则', '')
          //value.名称 = value.名称.replace('编码规则', '')


        });

        var columns = [
          {
            field: 'FBILLTYPEID',
            sortable: true,
            width: 170,
            title: '单据id'
          }, {
            field: '单据编码',
            sortable: true,
            width: 170,
            title: '单据编码'
          }, {
            field: '名称',
            width: 210,
            sortable: true,
            title: '名称'
          }, {
            field: '描述',
            sortable: true,
            title: '描述'
          }, {
            field: '表名',
            sortable: true,
            title: '单据明细表'
          }]

        ui.showTab('#单据类型tab', columns, rows)
      }

      查询用户账号(name) {
        //查询字段数据
        const ui = gd.reg.ui
        const se = gd.reg.se

        var vn = {
          "erp/T_SEC_USER": {
            // "@column": "FBILLTYPEID,FNUMBER.单据编号,FBILLFORMID.单据编码 ",
            //"FISDEFAULT": 1
          },
          "erp/T_BAS_USERLOGINRECORD": {
             "@column": "FUSERID,FDATETIME.max.m",
             "@group":"FUSERID"
            //"FISDEFAULT": 1
          },
          "erp/T_BAS_USERLOGINRECORD%ip": {
             "@column": "FUSERID,FCLIENTIP,FCOMPUTERNAME,FDATETIME",
             "FDATETIME|":"erp/T_BAS_USERLOGINRECORD.m",
             "FUSERID|":"erp/T_SEC_USER.FUSERID"
             
            //"FISDEFAULT": 1
          },
        }
        // //发送
        se.se(vn, pvs.datUrl, 'USER', '查询用户账号', ['查询用户账号2show'])
      }


      查询系统单据(name) {
        //查询字段数据
        const ui = gd.reg.ui
        const se = gd.reg.se

        /*
        T_META_TRACKERBILLTABLE
        
        select * f T_META_OBJECTTYPE_L
        
         select * from T_META_TOPCLASS_L
        
        T_BF_TABLEDEFINE
        
        //----表结构
        
         SELECT lookups.fid, lookups.fformid, lookups.ftablename, lookups.fpkfieldname, lookups.fpkfieldtype,
         lookups.FNameIsLocale, lookups.fnumberfieldname, lookups.fnamefieldname, lookups.forgfieldname, lookups.furl, 
         formslang.fname, forms.fsubsysid, subsys.fname fsubsysname
         FROM T_META_LOOKUPCLASS lookups INNER JOIN
         T_META_OBJECTTYPE forms ON forms.fid = lookups.fformid LEFT OUTER JOIN 
         T_META_OBJECTTYPE_L formslang ON (formslang.fid = forms.fid AND formslang.FLocaleId = 2052)
          LEFT OUTER JOIN T_META_SUBSYSTEM_L subsys  ON (forms.fsubsysid = subsys.fid AND subsys.FLocaleId = 2052) 
         
        ----
        select * from T_META_OBJECTTYPE
        where fid = 'SAL_SaleOrder'  --数据库表结构都在xml字段中 TextField. FieldName中
        formMetadata.businessInfo.BusinessInfo.Elements.BaseDataFieId.FieIdname=》Name   TableName
                                                        orgfieId
        
        
        
        
        */
        var vn = {
          "erp/T_BAS_BILLTYPE": {
            "@column": "FBILLTYPEID,FNUMBER.单据编号,FBILLFORMID.单据编码 ",
            "FISDEFAULT": 1
          },
          "erp/T_BAS_BILLTYPE_L": {
            "@column": "FBILLTYPEID,FNAME.名称,FDESCRIPTION.描述",
            "FLOCALEID": 2052,
            "FBILLTYPEID|": "erp/T_BAS_BILLTYPE.FBILLTYPEID"
          },
          "erp/T_BF_TABLEDEFINE": {
            "@column": "FTABLENUMBER.表名,FFORMID.单据编码,FENTITYKEY.表主键",
            "FFORMID|": "erp/T_BAS_BILLTYPE.单据编码"
          },

        }
        // vn = {
        //   "T_BAS_BILLCODERULE": {//T_BAS_BILLTYPE
        //     "@column": "FRULEID.规则id,FBILLFORMID.单据编码",
        //     "FDOCUMENTSTATUS": "C"
        //   },
        //   "T_BAS_BILLCODERULE_L": {//T_BAS_BILLTYPE_L
        //     "@column": "FRULEID.规则id,FNAME.名称,FDESCRIPTION.描述",
        //     "FRULEID|": "T_BAS_BILLCODERULE.规则id", "FLOCALEID": 2052
        //   }
        // }
        // -----T_META_OBJECTTYPE_L 也可以查单据
        // //发送
        se.se(vn, pvs.datUrl, 'BILLTYPE', '查询系统单据', ['查询系统单据2show'])
      }


      查询代办任务(流程状态) {
        //查询数据
        const ui = gd.reg.ui
        const se = gd.reg.se
        //gd.storage.set('searchTab', pvs.searchTab)

        //if (!pvs.searchTab) { return }

        //---加入查询条件
        console.log('查询代办任务', '流程状态=', 流程状态)
        var FSTATUS
        var CREATETIME = `>${moment().subtract(5, 'days').format('YYYY-MM-DD')}`
        if (!_.isEmpty(流程状态)) {
          if (流程状态 == "处理中") { FSTATUS = 2; CREATETIME = undefined }
          if (流程状态 == "已完成") { FSTATUS = 1 }
          if (流程状态 == "错误") { FSTATUS = 3; CREATETIME = undefined }


        }
        console.log('查询代办任务', '流程状态=', 流程状态, 'FSTATUS=', FSTATUS)



        //动画效果
        ui.loginLoading(1)
        ui.spto(1) //loading 
        //查询用户
        var vn = {
          "erp/T_WF_PROCINST": {
            "@column": "FPROCDEFID.流程id,FPROCINSTID.流程实例id,FSTATUS.流程状态,FBILLNO.单据编号",
            "FSTATUS": FSTATUS,
            "FCREATETIME&": CREATETIME,
            //'FPROCINSTID|': "erp/T_WF_ASSIGN.流程实例id"
          },
          "erp/T_WF_ASSIGN": {
            "@column": "FCREATETIME.日期,FSTATUS.节点状态,FASSIGNID.任务id,FPROCINSTID.流程实例id,FACTINSTID.节点id",
            // 'FNUMBER*':'XSDD000048_20230718184628'
            "FPROCINSTID|": "erp/T_WF_PROCINST.流程实例id",
            "@order": "-日期"
          },
          "erp/T_WF_RECEIVER": {
            "@column": "FASSIGNID.任务id,FRECEIVERID.接收人id,FTITLE.标题,FCONTENT.内容",
            "FASSIGNID|": "erp/T_WF_ASSIGN.任务id"
          },
          "erp/T_SEC_USER": {
            "@column": "FUSERID.接收人id,FNAME.名字",
            'FUSERID|': "erp/T_WF_RECEIVER.接收人id"
          },


          "erp/T_WF_PROCDEF_L": {
            "@column": "FPROCDEFID.流程id,FDISPLAYNAME.流程名",
            "FLOCALEID": 2052,
            'FPROCDEFID|': "erp/T_WF_PROCINST.流程id"
          },
          "erp/T_WF_ACTINST_L": {
            "@column": "FACTINSTID.节点id,FACTNAME.节点名称",
            'FACTINSTID|': "erp/T_WF_ASSIGN.节点id", "FLOCALEID": 2052
          },
          "erp/T_WF_ACTINST": {
            "@column": "FACTINSTID.节点id,FCREATETIME.节点开始,FCOMPLETEDTIME.节点完成",
            'FACTINSTID|': "erp/T_WF_ASSIGN.节点id"
          },

          "erp/T_WF_APPROVALASSIGN": {//任务详情
            "@column": "FASSIGNID.任务id,FKEYVALUE.单据id,FOBJECTTYPEID.单据类别",
            "FASSIGNID|": "erp/T_WF_ASSIGN.任务id"
          },//标准编码规则
          "erp/T_BAS_BILLCODERULE": {//T_BAS_BILLTYPE
            "@column": "FRULEID.规则id,FBILLFORMID.单据类别",
            'FBILLFORMID|': "erp/T_WF_APPROVALASSIGN.单据类别",
            "FDOCUMENTSTATUS": "C"
          },
          "erp/T_BAS_BILLCODERULE_L": {//T_BAS_BILLTYPE_L
            "@column": "FRULEID.规则id,FNAME.单据全称",
            "FRULEID|": "erp/T_BAS_BILLCODERULE.规则id", "FLOCALEID": 2052
          }
          /*,
          "T_SAL_ORDER": {//
            "@column": "FID.单据id,FCREATORID.制单人,FBILLTYPEID.单据类型id",
            "FID|": "T_WF_APPROVALASSIGN.单据id"
          },
          "T_BAS_BILLTYPE_L": {
            "@column": "FBILLTYPEID.单据类型id,FNAME.单据类型",
            "FBILLTYPEID|": "T_SAL_ORDER.单据类型id"
            , 'FLOCALEID': 2052
          }
         */
        }
        //获取数据，发送请求

        // //发送
        se.se(vn, pvs.datUrl, 'ASSIGN', '查询代办任务', ['查询代办任务2show'])
      }
      查询代办任务2show() {
        //跳转、翻页
        const ui = gd.reg.ui
        var dat = pvs.rawDat['T_WF_ASSIGN']//工作流任务
        console.log('查询代办任务2show', pvs.rawDat)
        var 工作流任务 = new dfd.DataFrame(pvs.rawDat['erp/T_WF_ASSIGN'])
        var 任务信息 = new dfd.DataFrame(pvs.rawDat['erp/T_WF_RECEIVER'])
        var 用户信息 = new dfd.DataFrame(pvs.rawDat['erp/T_SEC_USER'])
        var 工作流信息 = new dfd.DataFrame(pvs.rawDat['erp/T_WF_PROCDEF_L'])
        var 工作流实例 = new dfd.DataFrame(pvs.rawDat['erp/T_WF_PROCINST'])
        var 当前节点名 = new dfd.DataFrame(pvs.rawDat['erp/T_WF_ACTINST_L'])
        var 当前节点 = new dfd.DataFrame(pvs.rawDat['erp/T_WF_ACTINST'])
        var 任务详情 = new dfd.DataFrame(pvs.rawDat['erp/T_WF_APPROVALASSIGN'])
        var 单据编码 = new dfd.DataFrame(pvs.rawDat['erp/T_BAS_BILLCODERULE'])
        var 单据全称 = new dfd.DataFrame(pvs.rawDat['erp/T_BAS_BILLCODERULE_L'])

        //var 销售订单 = new dfd.DataFrame(pvs.rawDat['erp/T_SAL_ORDER'])
        //var 单据类型 = new dfd.DataFrame(pvs.rawDat['erp/T_BAS_BILLTYPE_L'])
        //----
        // 工作流任务.print()
        // 任务信息.print()
        // 用户信息.print()
        // 工作流信息.print()
        // 工作流实例.print()
        // 当前节点.print()
        // 任务详情.print()
        // 单据编码.print()
        // 单据全称.print() //去掉 标准编码规
        //销售订单.print()
        //单据类型.print()
        let rows = []
        try {

          let 工作流任务v2 = dfd.merge({ "left": 工作流实例, "right": 工作流任务, "on": ["流程实例id"], how: "inner" })
          工作流任务v2 = dfd.merge({ "left": 工作流任务v2, "right": 任务信息, "on": ["任务id"], how: "left" })
          工作流任务v2 = dfd.merge({ "left": 工作流任务v2, "right": 用户信息, "on": ["接收人id"], how: "left" })
          工作流任务v2 = dfd.merge({ "left": 工作流任务v2, "right": 工作流信息, "on": ["流程id"], how: "left" })
          工作流任务v2 = dfd.merge({ "left": 工作流任务v2, "right": 当前节点名, "on": ["节点id"], how: "left" })
          工作流任务v2 = dfd.merge({ "left": 工作流任务v2, "right": 当前节点, "on": ["节点id"], how: "left" })
          工作流任务v2 = dfd.merge({ "left": 工作流任务v2, "right": 任务详情, "on": ["任务id"], how: "left" })
          工作流任务v2 = dfd.merge({ "left": 工作流任务v2, "right": 单据编码, "on": ["单据类别"], how: "left" })
          工作流任务v2 = dfd.merge({ "left": 工作流任务v2, "right": 单据全称, "on": ["规则id"], how: "left" })


          工作流任务v2.sortValues("流程实例id", { ascending: false, inplace: true })
          工作流任务v2.print()
          rows = dfd.toJSON(工作流任务v2)

          工作流实例.print()

          _.forEach(rows, function (value, key) {
            //整理数据

            value.标题 = value.标题.split('\n')[0]

            value.节点状态 = value.节点状态 == 1 ? '完成' : '进行中'//1 or 0

            var stat = { 0: "准备", 1: "完成", 2: "挂起", 3: "错误", 4: "终止", 5: "暂停", }
            value.流程状态 = stat[value.流程状态]
            value.单据全称 = value.单据全称.replace('标准编码规则', '')
            value.流程实例id = `<a onclick="er.emit('看指定流程','${value.流程实例id}') " href="#">${value.流程实例id}</a>`
            value.单据全称 = `<a onclick="er.emit('看指定单据','${value.单据id}','${value.单据类别}') " href="#">${value.单据全称}</a>`


            const date1 = moment(value.节点开始);
            let date2 = _.isNull(value.节点完成) ? moment() : moment(value.节点完成);
            //console.log('时间==',value.节点开始, value.节点完成 ,moment()  )

            const date3 = date2.diff(date1, 'minute');//计算相差的分钟数
            const h = Math.floor(date3 / 60);//相差的小时数
            //console.log(value.节点开始,value.节点完成,h)
            value.处理时长 = _.isNaN(h) ? '无' : h


          });

        } catch (err) {
          console.log(err)

        }

        var columns = [{
          field: '流程实例id',
          width: 170,
          sortable: true,
          title: '流程id'
        }, {
          field: '日期',
          sortable: true,
          width: 170,
          title: '日期'
        }, {
          field: '单据编号',
          sortable: true,
          title: '单据编号'
        }, {
          field: '流程名',
          title: '流程名'
        }, {
          field: '节点名称',
          title: '节点名称'
        }, {
          field: '名字',
          sortable: true,
          title: '处理人'
        }, {
          field: '节点状态',
          title: '节点状态'
        }, {
          sortable: true,
          field: '单据全称',
          title: '单据'
        }, {
          sortable: true,
          field: '流程状态',
          title: '流程状态'
        }, {
          sortable: true,
          field: '处理时长',
          title: '经过时长(小时)'
        }]

        ui.showTab('#代办任务tab', columns, rows)
      }



      binding(dat, name, info, next = '') {
        //数据收集挂在到dat
        const ui = gd.reg.ui
        const se = gd.reg.se
        //数据挂在到dat
        //console.log('binding==', name, info)
        ui.loginLoading(0)
        ui.spto(0)
        if (dat.data['@code'] < 300) {
          //数据让如rawDat中
          ui.showInfo(dat.data['@msg'], info)
          //读取数据到 pvs
          var number = 0
          _.forEach(dat.data, function (value, key) {
            if (key.substr(0, 1) == '@') { return }
            pvs.rawDat[key] = dat.data[key]
            number = number + dat.data[key].length//行数
            if (dat.data[key].length > 0) {
              console.log(key + '==', dat.data[key].length, dat.data[key][0])
            } else {
              console.log(key, info, '上无数据')
            }
          });
          console.log(info + '加载', number, '行')
          ////下一步事件
          if (_.isString(next)) { er.emit(next) }
          //下一批事件
          if (_.isArray(next)) { _.map(next, (n) => { er.emit(n) }) }
        } else {
          ui.showInfo('出现错误', info)
          console.log('出现错误', info + '==', dat)
        }
      }
      se(vn, url, name, info, next = '') {
        //单发送请求
        const se = gd.reg.se

        axios.post(url + '?' + name, vn, se.hd)
          .then(dat => {
            se.binding(dat, name, info, next)
          })
          .catch(err => {
            se.getErr(err, name, info)
          })
      }


      getErr(error, naem, info) {
        //请求错误处理
        const ui = gd.reg.ui
        const se = gd.reg.se
        console.log('Error:', error, naem);
        ui.loginLoading(0) //loading 
        ui.spto(0) //loading  
        ui.showInfo('无法加载到数据，刷新重试', info) //loading  
      }
    }

    //----------开始
    let appdat = {
      setup() {
        const oui = new pgui(); //界面更改"方法"
        const se = new select(); //界面更改"方法"
        //const ocls = new cls(12);//默认选择
        //---放入全局解决this问题
        //gd.ocls = ocls; //抽奖类
        //gd.oin = oin; //通信逻辑
        gd.oui = oui; //ui界面

        //watch(gd.pd, oui.watchPg, { deep: true });
        //pvs.opList = computed(() => oui.showOp('', '')); //二次计算pvs.opList
        //------

        //onMounted(() => ocls.bindEvt()); //窗口大小变动事件
        //onMounted(() => oui.remount()); //已经登入刷新处理
        onMounted(() => er.emit('查询代办任务')); //已经登入刷新处理

        //--变量关联到html的映射 js访问要加.value
        return { er, "pd": gd.pd, "ref_login_manage": gd.pd.refManageEmt, }
      }
    }
    const app = createApp(appdat)
    //app.use(Quasar) //vue的ui
    app.mount('#q-app')
  </script>



</body>

</html>